/**
 *解析完成的每个DM都需要引入该js用于媒体的显示渲染
 */

var media = new Media();

/*=====================================cgm =================================  */
function hotLink(id,hotId){
	media.getMedia(id).newHighLight(hotId);
}
function removeAllHotLinks(){
	cgm.clearHighLight();
}
//cgm热点交互待处置,必须ie9
function callBack(id,name,icn){
	if($('#table-media').find('tr').length>0&&$('tr[id="'+name+'"]').length>=0){
	var pp="<tr id='xx'></tr>";
	clickCgm(pp);
	$('#table-media').find('tr').css('background-color','#fff');
	if($('#'+name).length>0){
	$('#'+name).css('background-color','#FFFF33');
	$(".home-d-b-content").scrollTop($('#'+name).position().top);
	}
	}
	else{ 
		var tag=$('a[name="hotspot"][hotspot="'+name+'"][infoEntityIdent="'+icn+'"]');
		if(tag.length>0){
		$('a[name="hotspot"][infoEntityIdent="'+icn+'"]').css('background-color','');
		tag.css('background-color','#FFFF33');	
		$(".home-d-b-content").scrollTop(tag.position().top-40);
	}
	}
}


function clickCgm(p){
	$('#table-media').find('tr').css('background-color','#fff');
	media.getMedia($('#ietm-media').children('div').children('object').attr('id')).newHighLight($(p).attr('id'),hotLinkType.name);
	$(p).css('background-color','#FFFF33');

}
/****************************************************************************/

$(function(){
	$('img').each(function(){
		if("symbol"!==$(this).attr('alt')&&$(this).attr('src').indexOf("tip.png")<0&&$(this).attr('src').indexOf("CGM.png")<0&&$(this).attr('src').indexOf("pdf.png")<0&&$(this).attr('src').indexOf("3D.png")<0&&$(this).attr('src').indexOf("b.png")<0&&$(this).attr('src').indexOf("l.png")<0)
		{
			$(this).attr("height",'300');
			var content="<div style='width:1200px;height:500px; vertical-align: middle; text-align: center;'><img src='"+$(this).attr('src')+"' /></div>"
			
			var name=$(this).attr('src').substring($(this).attr('src').lastIndexOf("/")+1,$(this).attr('src').lastIndexOf("."))
			if(name.indexOf("html")>-1){
			    name="";
			}
			$(this).dblclick(function(){
				 var index =  top.layer.open({
					  type: 1,
					  title: '多媒体显示 &nbsp;&nbsp; '+name,
					  content: content,
					  resize:false,
					  area: ['800px', '550px'],
					  maxmin: true,
					  btn: ['关闭'],
					  yes: function(index, layero){
			    	  top.layer.close(index);
					  }
					});
				 top.layer.full(index);
			});
		}else{
		
		}
		
	});
	$(".thumbnail").click(function(){
		//视频
		if($(this).find('param[name="URL"]').val()){
		var top1=$(this).position().top;
		var src1=$('#publiciframe').attr('src');
		var url=$(this).find('param[name="URL"]').val();
		content= '<div style="height:500px;width:100%;text-align:center;">'
		 	  +'<object id="MediaPlayer" width="100%" height="500px"  classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">'
		 	  +'<param name="windowlessVideo" value="1"/>'
		 	  +'<param name="ShowPositionControls" value="0"/>'
		      +'<param name="AutoStart" value="0"/>'
		 	  +'<param name="EnableContextMenu" value="0"/>'  
		 	  +'<param name="URL" value='+url+' />' 
		 	  +'</object></div>';
		 var index =  top.layer.open({
			  type: 1,
			  title: $(this).children('div').text(),
			  content: content,
			  resize:false,
			  area: ['800px', '550px'],
			  maxmin: true,
			  btn: ['关闭'],
			  yes: function(index, layero){
	    	  top.layer.close(index);
			  }
			});
		 top.layer.full(index);
		 content='';
	}

		if($(this).find('param[name="movie"]').val()){
		var top1=$(this).position().top;
		var src1=$('#publiciframe').attr('src');
		var url=$(this).find('param[name="movie"]').val();
		 content= '<div style="height:500px;width:100%;text-align:center;">'
			 +'<object id="flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="1200px"  height="500px" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">'
			 +'<param name="movie" value='+url+'>'
			 +'<param name="quality" value="high">'
			 +'<param name="bgcolor" value="#F0F0F0">'
			 +'<param name="menu" value="false">'
			 +'<param name="wmode" value="opaque">'
			 +'<param name="FlashVars" value="">'
			 +'<param name="allowScriptAccess" value="sameDomain">'
			 +'</object></div>';
		 var index =  top.layer.open({
			  type: 1,
			  title: $(this).children('div').text(),
			  content: content,
			  resize:false,
			  area: ['800px', '550px'],
			  maxmin: true,
			  btn: ['关闭'],
			  yes: function(index, layero){
	    	  top.layer.close(index);
			  }
			});
		 top.layer.full(index);
		 content='';
	}
	
	});
})
var kkkk;//全屏方法调用
var kkkkId="";

function openPdf(id,url,fid){
	var content="";
	if(url.toLowerCase().indexOf('.pdf')>-1){
	top.pdfName=url;
	content="<iframe width='100%' src='viewer.html' height='100%' id='reportshow' name='reportshow' scrolling='no' frameborder='0'></iframe>";
	 var index =  top.layer.open({
		  type: 1,
		  title: fid+".pdf",
		  content: content,
		  resize:false,
		  area: ['800px', '550px'],
		  maxmin: true,
		  btn: ['关闭'],
		  yes: function(index, layero){
    	  top.layer.close(index);
		  },
		  end: function () {
				
          }
		});
	 top.layer.full(index);
	}
	kkkk=url;
	kkkkId=fid;
}
function openCgm(id,url,fid){
	var homedm = $(".home-d-m").outerHeight(true);
	 $(".home-d-b-content").height($(window).height()-homedm-98);
	if(!media.getMedia(id)||!$("#cgm_" + id).find("object").attr("id")){ 
		$('.home-d-b-tow').children('div:eq(0)').attr('class','home-d-b-towl');
		$('.home-d-b-towr').removeClass('active').show();
		$('#ietm-media').html('<div id=cgm_'+id+' style="width:100%;height:100%;"></div>');
		$("#cgm_" + id).html('');
		$("#cgm_" + id).html("<div id=\""+ id + "\"  style=\"width:100%;height:100%;\"></div>");
		cgm = media.createMedia({
			id : id,
			url : url,
			click : callBack
		});
	}
	else {
		if($('.home-d-b-towr').hasClass('active')){
			$('.home-d-b-tow').children('div:eq(0)').attr('class','home-d-b-towl');
			$('.home-d-b-towr').removeClass('active').show();
		}
	}
	kkkk=url;
	kkkkId=fid;
}

/**
 * 打开swf
 * @param url
 * @param title
 * @returns
 */
function openSWF(url,title){
	window.open (url,title,'top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=yes,location=no, status=no,fullscreen=yes') 
}


/*==============================================u3d========================  */		
function openU3D(id,targ,method,param,url,fid) {
	var homedm = $(".home-d-m").outerHeight(true);
	 $(".home-d-b-content").height($(window).height()-homedm-98);
if(!media.getMedia(id)){
	$('.home-d-b-tow').children('div:eq(0)').attr('class','home-d-b-towl');
	$('.home-d-b-towr').removeClass('active').show();
	$('#ietm-media').html('<div id=u3d_'+id+'></div>');
	$("#u3d_"+id).html("<div id=\"" + id + "\" style=\"width:100%;height:100%;\"></div>"); 
	var options = {
		id : id,
		url : url,
		width : "99%",
		height : 400
	};
	if(arguments.length > 1){
		$.extend(true, options, {
			init:{
				targ : targ,
				method : method,
				param : param
			}
		});
	}
	u3d = media.createMedia(options);
	kkkk=url;
	kkkkId=fid;
}
else{
	if($('.home-d-b-towr').hasClass('active')){
		$('.home-d-b-tow').children('div:eq(0)').attr('class','home-d-b-towl');
		$('.home-d-b-towr').removeClass('active').show();
	}
}

}

//网页调用U3d部件
function clickU3d(e){
	var homedm = $(".home-d-m").outerHeight(true);
	 $(".home-d-b-content").height($(window).height()-homedm-98);
	var u3d11 = media.getMedia($('#ietm-media').children('div').children('div').attr('id'));
	u3d11.getUnity().SendMessage(e.id,'onClick','');
}
function Unity3dHighLight(arg){
	$('a[name="u3dclick"]').css('background-color','');
	$('a[name="u3dclick"][id="'+arg+'"]').css('background-color','red');
	}

function openWrl(id,url,fid){
	var homedm = $(".home-d-m").outerHeight(true);
	 $(".home-d-b-content").height($(window).height()-homedm-98);
	url=top.requesturl+url;
	kkkk=url;
	kkkkId=fid;
	if(!media.getMedia(id)){
		$('.home-d-b-tow').children('div:eq(0)').attr('class','home-d-b-towl');
		$('.home-d-b-towr').removeClass('active').show();
		$('#ietm-media').html('<div id=wrl_'+id+'></div>');
		$("#wrl_" + id).html("<div id=\""+ id + "\"></div>");
		wrl = media.createMedia({
			id : id,
			url : url,
			height : 400,
			width : 340
		});
	}
	else{
		if($('.home-d-b-towr').hasClass('active')){
			$('.home-d-b-tow').children('div:eq(0)').attr('class','home-d-b-towl');
			$('.home-d-b-towr').removeClass('active').show();
		}
	}
}

function startMovie(id,obj, fn, param) {
	var u3d = media.getMedia(id);
	if (u3d && u3d.getUnity()) {
		u3d.getUnity().SendMessage(obj, fn, param);
	}
}
/**
 * 注释创建和删除
 */
function createNote(pageX,pageY,event){//
		var dmCode=$('.home-d-t-content table tbody tr:eq(1) td:eq(1)').text();
		var version=$('.home-d-t-content table tbody tr:eq(2) span').text();
		var date=new Date();
		var nodeForm = new NoteForm({
			subTitle : dmCode,
			version:version,
			publishDate:date.toLocaleDateString()
		});
		nodeForm.submit({
			url : '/ietm/saveNote',
			type : 'POST',
			success : function(form,data){
				if(data.id){
					new Note({
						id : "anno-"+data.id,
						content : $(form.content).val(),
						x : pageX,
						y : pageY,
						del:function(){
							$.ajax({
								  async:'false',
								  type: "GET",
								  url: "/ietm/delNote",
								  data:"id="+data.id,
								  success:function(data){
									  if(data==='success'){
						    		    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">删除成功!</div></div>', {
						    			            'title':'提示',
						    			            'buttons':['确定']
						    			         });
										  return true;
									  }
								  }	 
						});
							return true;
						}
					});
					return true;
				}
				
			},
			data : {
				dmodelId:dmId,
				projectId:projectId,
				code:dmCode,
				dmCode:dmCode,
				posX:pageX,
				posY:pageY,
				version:version,
				publishDate:date.toLocaleDateString(),
				userName:top.userName,
				type:'comment'
			}
		});
}
/**
 * 创建tag
 * @param pageX
 * @param pageY
 * @param event
 * @returns
 */
function createTag(){
	var dmCode=$('.home-d-t-content table tbody tr:eq(1) td:eq(1)').text();
	var content= '<div class="project-view" id="tags">'
		+'<table width="400" align="center" cellpadding="0" cellspacing="0" >'
		+'<tr><td width="30%" align="right" id="dmCode">数据模块编码：</td><td width="70%">'+dmCode+'<input type="hidden" name="code" id="tags-code" value='+dmCode+'></td></tr>'
		+'<tr><td align="right">书签名：</td><td><input type="hidden" name="userName" value='+top.userName+'><input type="text" name="title" class="input-pub" id="tags-title"/><input type="hidden" id="dmodelId" name="dmodelId" value="111"></td></tr></table>'
		+'</div>';
	
	var diag = new $.Zebra_Dialog(content,{
		width : 600,
		title : '新增',
	    buttons:  [
	               {caption: '保存', callback: function() { 
	            	   $.ajax({
           	            url:  encodeURI('/ietm/saveMarker'),//?code='+$('#tags-code').val()+"&title="+$('#tags-title').val()+"&dmodelId="+dmId+"&checked=0"),
           	            type: 'post',
           	            data:{'code':$('#tags-code').val(),
           	            	  'title':$('#tags-title').val(),
           	            	  'checked':0},
		    		    success: function (data) {
		    		    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">保存成功!</div></div>', {
		    			            'title':'提示',
		    			            'buttons':['确定']
		    			         });
		    		     }
           	        });  
	       		  
	                  }}
	                ]
	});
	content='';
}

var dmId=$("#dmId", parent.document).val();
var projectId=$("#projectId", parent.document).val();
$(function() {
	
	//cgm u3d 右侧div关闭
	$('.cgmu3dclose').click(function(){
		$('.home-d-b-tow').children('div:eq(0)').removeClass('home-d-b-towl');
		$('.home-d-b-towr').addClass('active');
		//$('.home-d-b-towl').addClass('active');
	});

	$('.fullscreen').click(function(){
		$('.home-d-b-towr').addClass('active');
		$('.home-d-b-towl').addClass('active');
		content='';
		if(kkkk.indexOf('.swf')>-1)
			 content= '<div style="height:500px;">'
						 +'<object id="flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%"  height="400px" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">'
						 +'<param name="movie" value='+kkkk+'>'
						 +'<param name="quality" value="high">'
						 +'<param name="bgcolor" value="#F0F0F0">'
						 +'<param name="menu" value="false">'
						 +'<param name="wmode" value="opaque">'
						 +'<param name="FlashVars" value="">'
						 +'<param name="allowScriptAccess" value="sameDomain">'
						 +'<embed src="'+kkkk+'" quality="high" bgcolor="#ffffff" width="100%"  height="400px" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> ' 
						 +'</object></div>';
			else if(kkkk.indexOf('.avi')>-1||kkkk.indexOf('.wmv')>-1||kkkk.indexOf('.mpg')>-1||kkkk.indexOf('.mpeg')>-1)
				 content= '<div style="height:500px;">'
					 	  +'<object id="MediaPlayer" width="100%"   classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject">'
					 	  +'<param name="ShowPositionControls" value="0"/>'
					      +'<param name="AutoStart" value="0"/>'
					 	  +'<param name="EnableContextMenu" value="0"/>'  
					 	  +'<param name="URL" value='+kkkk+' />' 
					 	  +'</object></div>';  
			else if(kkkk.indexOf('.unity3d')>-1)
				 content= '<div style="height:100%;">'
							 +'<object id="u3ds" classid="CLSID:444785F1-DE89-4295-863A-D46C3A781394" width="100%"  height="100%" display:block >'
							 +'<param name="src" value='+kkkk+'/>'
							 +'<param name="firstFrameCallback" value="UnityObject2.instances[0].firstFrameCallback();">'
							 +'<param name="enableDebugging" value="0">'
							 +'<param name="disableContextMenu" value="true">'
							 +'</object></div>';
			else if(kkkk.indexOf('.cgm')>-1||kkkk.indexOf('.CGM')>-1)
				 content= '<div style="height:600px;">'
							 +'<object id="cgms" classid="CLSID:1D4A81CB-25A3-4EB7-A75E-4F8A5386D8F8" width="100%"  height="100%" data='+kkkk+'></object></div>';
			else if(kkkk.indexOf('.wrl')>-1||kkkk.indexOf('.WRL')>-1){
				content='<div id="ietm-media" style="height: 550px;text-align: center;">'
				+'<object width=90% height="550" id="402881225ec2a6fd015ec2ae5e00097a" classid="CLSID:86A88967-7A20-11D2-8EDA-00600818EDB1" type="application/x-oleobject">'
				+'<param name="ConsoleMode" value="1">'
				+'<param name="src" value='+kkkk+'/>'
				+'<param name="ContextMenu" value="True">'
				+'<param name="CpuLoading" value="80">'
				+'<param name="LoadDroppedScene" value="False">'
				+'<param name="NavigationBar" value="1">'
				+'<param name="RendererHints" value="5168">'
				+'<param name="RendererName" value="DirectX Renderer">'
				+'<param name="RendererOptimization" value="0">'
				+'<param name="ShowLogo" value="False">'
				+'<param name="Skin" value="{46BB95BF-8EB4-481A-A1EF-50D43FC32B9D};">'
				+'<param name="TravelSpeed" value="1">'
				+'<param name="viewpoint_transition_mode" value="0">'
				+'<param name="WaitForAllResources" value="True">'
				+'<param name="BackColor" value="&amp;hC08080">'
				+'</object>'
				+'</div>'
			}
			  
		
			 
			 var index =  top.layer.open({
				  type: 1,
				  title: '多媒体显示 &nbsp;&nbsp; '+(kkkkId==undefined?"":kkkkId),
				  content: content,
				  resize:false,
				  area: ['800px', '850px'],
				  maxmin: true,
				  btn: ['关闭'],
				  yes: function(index, layero){
		    	  top.layer.close(index);
				  }

				});
			 top.layer.full(index);
			 content='';
	});

	
	//显示隐藏信息

	//右键添加注释
	$.disabledContextMenu();
	$.mouseMoveShow({
		id : "ui-menu",
		items : [{
			text : "添加注释",
			handle : createNote 
		},{
			text : "添加书签",
			handle : createTag
		}]
	});
	//页面加载完成后动态渲染书签到页面中			      
	$.getJSON("/ietm/findByDmCode?dmCode="+$('.home-d-t-content table tbody tr:eq(1) td:eq(1)').text(),function(data){
	  renderNotes(data);
	  });
	
	$('a').each(function(){
		//热点交互
		if($(this).attr('hotspot')&&$(this).attr('infoEntityIdent')){
			$(this).click(function(){
				openCgm($(this).attr('infoEntityIdent'),'/html/'+top.projectCode+'/'+$(this).attr('infoEntityIdent')+'.cgm');
				media.getMedia($(this).attr('infoEntityIdent')).newHighLight($(this).attr('hotspot'),hotLinkType.name);
				$('a[name="hotspot"][infoEntityIdent="'+$(this).attr('infoEntityIdent')+'"]').css('background-color','');
				$(this).css('background-color','#FFFF33');
			});
		
		}else{
			if($(this).attr('id')=='btn_syb'){
				$(this).children('img').attr('src',$(this).children('img').attr('src').replace('btn_syb','btn_syb_disable'));
			}else if($(this).attr('id')=='btn_xyb'){
				$(this).children('img').attr('src',$(this).children('img').attr('src').replace('btn_xyb','btn_xyb_disable'));
			}else if($(this).attr('id')=='btn_cxgl'){
				$(this).children('img').attr('src',$(this).children('img').attr('src').replace('btn_cxgl','btn_cxgl_disable'));
			}
		}
	});
	//fullScr();
	$(".home-d-b-content").scrollTop(top.posY);
	var inde=0;
	var sum=0;
	var cliType=""
	var totalStep=$('a[name=procedural_step_start]').length;
	//单步浏览
	$('#btn_db').click(function(){
		if($(this).children('img').attr('src').indexOf('disable')<0){
			cliType='db';
			inde=0;
			if(inde===0){
				dull(inde);	
				inde++;
				$(this).children('img').attr('src',$(this).children('img').attr('src').replace('btn_db','btn_db_disable'));
				$('#btn_syb').children('img').attr('src',$('#btn_syb').children('img').attr('src').replace('btn_syb_disable','btn_syb'));
				$('#btn_xyb').children('img').attr('src',$('#btn_xyb').children('img').attr('src').replace('btn_xyb_disable','btn_xyb'));
			}else{
			}
		}
	
		});
	//单步浏览上一步
	$('#btn_syb').click(function(){
		if($(this).children('img').attr('src').indexOf('disable')<0){
			if(inde>0){
				if(cliType=='db'){
					dull(0);
			    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">已是第一步!</div></div>', {
				            'title':'提示',
				            'buttons':['确定']
				         });
				}
				else{
					if(inde<totalStep){
						inde=inde-1;
						dull(inde);
					}else{
						inde=inde-1;
						dull(inde);
					}	
				}
				
			}else{
				if(cliType=='db'||cliType=='xyb'){
					dull(0);
			    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">已是第一步!</div></div>', {
				            'title':'提示',
				            'buttons':['确定']
				         });
				}else{
					$.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">请点击单步浏览!</div></div>', {
				            'title':'提示',
				            'buttons':['确定']
				         });

					dull(-1);
					return ;
				}
			}
		}
	
	});
	//单步浏览下一步
	$('#btn_xyb').click(function(){
		if($(this).children('img').attr('src').indexOf('disable')<0){
			if((inde===0&&cliType=='')||inde===-1){
				$.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">请点击单步浏览!</div></div>', {
		            'title':'提示',
		            'buttons':['确定']
		         });
				return ;
			}
			if(cliType!='db')
				inde++;
			
			if(inde<totalStep){
				dull(inde);
				cliType='xyb';
			}else{
				$.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">已是最后一步!</div></div>', {
		            'title':'提示',
		            'buttons':['确定']
		         });			
				inde=-1;
				dull(inde);
				$('#btn_db').children('img').attr('src',$('#btn_db').children('img').attr('src').replace('btn_db_disable','btn_db'));
				$('#btn_syb').children('img').attr('src',$('#btn_syb').children('img').attr('src').replace('btn_syb','btn_syb_disable'));
				$('#btn_xyb').children('img').attr('src',$('#btn_xyb').children('img').attr('src').replace('btn_xyb','btn_xyb_disable'));
			}
		}
		
	});
	

	//开始隔离
	var stp_num=2;
	$('#btn_ksgl').click(function(){
		$('#stp-0001').show().css('border',"1px solid #f00");
		$('#stp-0001').children('.subtitle').children('.blank').text('1');
		$(".home-d-b-content").scrollTop($('#stp-0001').children('.subtitle').children('.blank').position().top);
		$(this).children('img').attr('src',$(this).children('img').attr('src').replace('btn_ksgl','btn_ksgl_disable'));
	 $('#btn_cxgl').children('img').attr('src',$('#btn_cxgl').children('img').attr('src').replace('btn_cxgl_disable','btn_cxgl'));
	});
	//重新隔离
	/**
	 * 修改 重新隔离
	 * 点击重新隔离之后开始隔离显示
	 */
	$('#btn_cxgl').click(function(){
		//使当前页面radio可以点击
		$('input[type="radio"]').removeAttr('disabled');
		$("div[id^='stp-']").hide();
		$('#btn_ksgl').children('img').attr('src',$('#btn_ksgl').children('img').attr('src').replace('btn_ksgl_disable','btn_ksgl'))
		$(this).children('img').attr('src',$(this).children('img').attr('src').replace('btn_cxgl','btn_cxgl_disable'));
		stp_num=1;
		
	});
	
	//点击是否单选框
	$('input[type="radio"]').click(function(){
		$("div[id^='stp-']").css('border','');
		var pid=$(this).parent('div').attr('id');
		$('#'+$(this).attr('id').replace(pid+"_",'')).show().css('border',"1px solid #f00");
		$('#'+$(this).attr('id').replace(pid+"_",'')).children('.subtitle').children('.blank').text(''+stp_num);
		stp_num++;
			$('input[name='+$(this).attr('name')+']').attr('disabled','disabled');

			if('stp-0003_stp-0002'==$(this).attr('id')){
				var temobj = $("<div></div>");
				temobj.insertBefore($("#stp-0002"));
				$("#stp-0003").insertBefore(temobj);
				temobj.remove();
			}
	});
	
	 $(".home-zoom a").click(function(){
			var thisEle = $("#article").css("font-size"); //获取当前字体大小
			var textFontSize = parseInt(thisEle);//把当前字体大小转换为整数
			var className = $(this).attr("class");
			if(className == "bigger"){
					textFontSize += 1;
			}else if(className == "smaller"){
					textFontSize -= 1;
			}
			if(textFontSize>30||textFontSize<12){return;}//超出指定字体大小，停止运行
			$("#article").css("font-size",textFontSize+"px" );//赋值
		 });
	//警告，提示，注意弹出框

	 popDiag();
	 getContents();
	
});

function getContents(){
	
		var $ele = $('#content');
	   	var pcontents="<ul id='dmList' class='filetree1'>";
	   	var tabcontents="<li style='font-weight:bold;'><span>表格列表</span></li>";
	   	var piccontents="<li style='font-weight:bold;'><span>图片列表</span></li>";
	    var textcontents="<li style='font-weight:bold;'><span>文档内容</span></li>";
	   $ele.find("caption").each(function(){
		   tabcontents+="<li><span><a>"+$(this).text()+"</a></span></li>";
	   });
	   	pcontents+=tabcontents;
	   $ele.find(".textcenter").each(function(){
		 piccontents+="<li><span><a>"+$(this).text()+"</a></span></li>";
	   });			   	
	   	pcontents+=piccontents;
	   
	    $ele.find("p").each(function(){
			if($(this).attr('class')==='titleItalic'){
				textcontents+="<li><span><a>"+$(this).text()+"</a></span></li>";
				}
			else if($(this).attr('class')==='subtitle'){
				textcontents+="<li><span><a>"+$(this).text()+"</a></span></li>";
				}
			else if($(this).attr('class')==='heading'){
				textcontents+="<li><span><a>"+$(this).text()+"</a></span></li>";
			}
			else if($(this).attr('class')==='indent'){
				if($(this).text().indexOf("？")>=0){
					textcontents+="<li><span><a>"+$(this).text()+"</a></span></li>"; 							
				}
			}
			});			
	  pcontents+=textcontents;	
	  pcontents+="</ul>";
	  $('#dmCatalog', parent.document).html(pcontents);
}
//弹窗
function popDiag(){
	 $('div').each(function(index){
			if($(this).attr('class')==='warningborder'){
				 var msg = new Object();
				    msg.id="_"+index;
					msg.type = 'WARNING';
					msg.name = '警告';
					msg.text = $(this).find('.warnText').text();//document.getElementById('N101A1柴油机').innerHTML;
					msg.color = '#FF0000';
					addMessage(msg);
			}else if($(this).attr('class')==='cautionborder'){
				 var msg1 = new Object();
				   msg1.id="_"+index;
		       		msg1.type = 'CAUTION';
					msg1.name = '注意';
					var text11=$(this).find('.cautText').text();
					msg1.text = text11;
					msg1.color = '#FF0000';
					addMessage(msg1);
			}
		 });
		 displayMessages();
}

/**
 * 单步浏览
 * @param inde
 * @returns
 */
function dull(inde){
$('a[name=procedural_step_start]').each(function(index){
	if(""!=top.colorVal){
	$(this).next('.subtitle').css('background-color',top.colorVal);//'#fff'
	$(this).next('p[class="para"]').css('background-color','#fff').children().css('background-color',top.colorVal);
	}
	else{
		$(this).next('.subtitle').css('background-color','#fff');//'#fff'
		$(this).next('p[class="para"]').css('background-color','#fff').children().css('background-color','#fff');
	}
	if(index==inde){
		$(".home-d-b-content").scrollTop($(this).position().top);
		$(this).next('.subtitle').css('background-color','#FAFE87');
		$(this).next('p[class="para"]').css('background-color','#FAFE87').children().css('background-color','#FAFE87');
	}
});
}

//全屏
function fullScr(){
	
	$('.fullscreen').click(function(){
		var toWith=$('.home-d-b-towr').width();
		$('.home-d-b-towr').hide();
		$('.home-d-t-pub').width($('.home-d-t-pub').width()+toWith-300);
		$('.home-d-b-content').width($('.home-d-b-content').width()+toWith);
	});
}

/**
 * 页面加载成功渲染注释
 * 有问题一次全删除了，
 * @returns
 */
function renderNotes(rows){
	$(rows).each(function(i,obj){
		new Note({
			id : "anno-"+obj.id,
			content : obj.content,
			x:obj.posX,
			y:obj.posY,
			del:function(){
				$.ajax({
					  async:'false',
					  type: "GET",
					  url: "/ietm/delNote",
					  data:"id="+obj.id,
					  success:function(data){
						  if(data==='success'){
			    		    	 $.Zebra_Dialog('<div class="prompt"><div class="success-icon"></div><div class="success-title">删除成功!</div></div>', {
			    			            'title':'提示',
			    			            'buttons':['确定']
			    			         });
							  return true;
						  }
					  }	 
			});
				return true;
			}
		});
	});
}

//退出浏览器记录书签
function exitAddTag11(){
	var dmCode=$('.home-d-t-content table tbody tr:eq(1) td:eq(1)').text();
	var title=$('.dmtitle').text().replace(/[ ]/g,"").replace(/[\r\n]/g,"");
	$.ajax({
           url:  encodeURI('/ietm/commentTags/saveOrUpdate?code='+dmCode+"&title="+title+"&type=p&dmodelId="+top.dmId+"&projectId="+top.projectId+"&userName="+top.userName),
           type: 'post',
	    success: function (data) {}
       });
}

var current=0;//当前页面历史索引号
var currents=[];//存储历史记录
/**
 * 当前页面内部跳转需记录的数据
 * 1、通过dmCode 查询
 * 2、修改iframe的src
 * 3、存储dm信息到历史列表中
 * @param code
 * 是否需要调整看情况而定
 * @returns
 */
function refDM(dmCode){
	if(dmCode){
		$.ajax({
			  type: "GET",
			  url: "/ietm/getDmByDmCode",
			  data:"dmCode="+dmCode,
			  success:function(data){//每进行一次dm链接跳转就记录一次
				current=current++;
				currents.push(data);//不需要再次跳转因为有href处理
				location.href=data.url
			  }	 
	});
	}else{
		alert('数据模块不存在')
	}
	
}
/**
 * 
 * @param node
 * @returns
 */
function recordHistory(node){
	if (currentPos >= historyArr.length - 1){
        historyArr.push(node.id);
        currentPos = historyArr.length - 1;
    }else{
        historyArr.splice(currentPos + 1, 0, node.id);
        currentPos = currentPos + 1;
    }
}


